/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package py.com.peluq.model.entity;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Diego_M
 */
@Entity
@Table(name = "seccion", catalog = "peludb", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Seccion.findAll", query = "SELECT s FROM Seccion s"),
    @NamedQuery(name = "Seccion.findByIdseccion", query = "SELECT s FROM Seccion s WHERE s.seccionPK.idseccion = :idseccion"),
    @NamedQuery(name = "Seccion.findByIddeposito", query = "SELECT s FROM Seccion s WHERE s.seccionPK.iddeposito = :iddeposito"),
    @NamedQuery(name = "Seccion.findByIdsucursal", query = "SELECT s FROM Seccion s WHERE s.seccionPK.idsucursal = :idsucursal"),
    @NamedQuery(name = "Seccion.findBySecDescrip", query = "SELECT s FROM Seccion s WHERE s.secDescrip = :secDescrip")})
public class Seccion implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected SeccionPK seccionPK;
    @Column(name = "sec_descrip")
    private Integer secDescrip;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "seccion")
    private Collection<Stock> stockCollection;
    @JoinColumns({
        @JoinColumn(name = "iddeposito", referencedColumnName = "iddeposito", nullable = false, insertable = false, updatable = false),
        @JoinColumn(name = "idsucursal", referencedColumnName = "idsucursal", nullable = false, insertable = false, updatable = false)})
    @ManyToOne(optional = false)
    private Deposito deposito;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "seccion")
    private Collection<PedidoDet> pedidoDetCollection;

    public Seccion() {
    }

    public Seccion(SeccionPK seccionPK) {
        this.seccionPK = seccionPK;
    }

    public Seccion(int idseccion, int iddeposito, int idsucursal) {
        this.seccionPK = new SeccionPK(idseccion, iddeposito, idsucursal);
    }

    public SeccionPK getSeccionPK() {
        return seccionPK;
    }

    public void setSeccionPK(SeccionPK seccionPK) {
        this.seccionPK = seccionPK;
    }

    public Integer getSecDescrip() {
        return secDescrip;
    }

    public void setSecDescrip(Integer secDescrip) {
        this.secDescrip = secDescrip;
    }

    @XmlTransient
    public Collection<Stock> getStockCollection() {
        return stockCollection;
    }

    public void setStockCollection(Collection<Stock> stockCollection) {
        this.stockCollection = stockCollection;
    }

    public Deposito getDeposito() {
        return deposito;
    }

    public void setDeposito(Deposito deposito) {
        this.deposito = deposito;
    }

    @XmlTransient
    public Collection<PedidoDet> getPedidoDetCollection() {
        return pedidoDetCollection;
    }

    public void setPedidoDetCollection(Collection<PedidoDet> pedidoDetCollection) {
        this.pedidoDetCollection = pedidoDetCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (seccionPK != null ? seccionPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Seccion)) {
            return false;
        }
        Seccion other = (Seccion) object;
        if ((this.seccionPK == null && other.seccionPK != null) || (this.seccionPK != null && !this.seccionPK.equals(other.seccionPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "py.com.peluq.model.entity.Seccion[ seccionPK=" + seccionPK + " ]";
    }
    
}
